<?php
if (isset($_POST["whichForm"]))
	{
		switch ($_POST["whichForm"])
		{
			case "domain":
			if (isset($_POST['domain']) && isset($_SESSION['theso']))
			{
				if (isset($_POST['nomDo']))
				{
					$ajoutDo = pg_query($db, "SELECT * FROM UPDATE_DOMAIN ('".$_POST['domain']."','nom', '".$_POST['nomDo']."');");
				}
				if (isset($_POST['descDo']))
				{
					$ajoutDo = pg_query($db, "SELECT * FROM UPDATE_DOMAIN ('".$_POST['domain']."','description', '".$_POST['descDo']."');");
				}
				
			}
			break;
			
			case "concept": 
			{
				if (isset($_POST['addtg']) && $_POST['addtg'] == '+')
				{
					$ajoutTG = pg_query($db, "SELECT * FROM ADD_TG('".$_POST['curCon']."','".$_POST['TermeG']."');");
				}
				if (isset($_POST['addtg']) && $_POST['addtg'] == '-' && isset($_POST['listTG']) && isset($_POST['curCon']))
				{
					$remTG = pg_query($db, "SELECT * FROM REMOVE_TG('".$_POST['curCon']."','".$_POST['listTG']."', 'false');");
				}

				if (isset($_POST['addts']) && $_POST['addts'] == '+')
				{
					$ajoutTs = pg_query($db, "SELECT * FROM ADD_TS('".$_POST['curCon']."','".$_POST['TermeS']."');");
				}
				if (isset($_POST['addts']) && $_POST['addts'] == '-' && isset($_POST['listTS']) && isset($_POST['curCon']))
				{
					$remTG = pg_query($db, "SELECT * FROM REMOVE_TS('".$_POST['curCon']."','".$_POST['listTS']."', 'false');");
				}

				if (isset($_POST['addt']) && $_POST['addt'] == '+')
				{
					$ajoutT = pg_query($db, "SELECT * FROM ADD_TERMNVDT('".$_POST['Terme']."','".$_POST['curCon']."');");
				}
				if (isset($_POST['addt']) && $_POST['addt'] == '-' && isset($_POST['listT']) && isset($_POST['curCon']))
				{
					$remT = pg_query($db, "SELECT * FROM REMOVE_TERMNVDT('".$_POST['listT']."');");
					if ($remT == -1)
					{
						echo "chatte";
					}
				}
				if (isset($_POST['maj']) && $_POST['maj'] == 'Mettre à jour' && $_POST['newTermeV'] != '')
				{
					$maj = pg_query($db, "SELECT * FROM UPDATE_CONCEPT('".$_POST['termeV']."','nom', '".$_POST['newTermeV']."');");
				}
			}
			break;

			case "assoc":
			if (isset($_POST['newName']) && isset($_POST['assoc']))
			{
					$updateAssoc = pg_query($db, "SELECT * FROM UPDATE_ASSOCIATION ('".$_POST['assoc']."','nom','".$_POST['newName']."');");
			}
			break;
		}
	}
?>
